home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / e / dclistview.lha / dclisttest.e < prev    next >
Text File  |  1999-01-19  |  2KB  |  68 lines

  1. OPT PREPROCESS, OSVERSION=37
  2.  
  3. MODULE 'tools/exceptions', 'tools/EasyGUI', 'exec/nodes', 'exec/lists',
  4.        'plugins/dclistview', 'tools/constructors', 'utility/tagitem',
  5.        '*fonts', 'graphics/text'
  6.  
  7. DEF result=-1
  8. DEF deffixedfont:PTR TO textfont
  9.  
  10. PROC main() HANDLE
  11.   DEF dclist:PTR TO dclistview
  12.   DEF list, a, nodes, attr:PTR TO textattr
  13.  
  14. -> let's make up a quick list
  15.   list:=newlist()
  16.   nodes:=['zero','one','two','three','four','five','six','seven',
  17.           'eight','nine','ten','eleven','twelve','thirteen','fourteen']
  18.   ForAll({a}, nodes, `AddTail(list, newnode(NIL, a)))
  19.   getdeffonts()  -> Let's use the screen's fixed width font
  20.                  -> Ugly alert: Gadtools uses this font for the label as well
  21.   attr:=[deffixedfont::ln.name, deffixedfont.ysize, deffixedfont.style, deffixedfont.flags]:textattr
  22.  
  23.   NEW dclist.dclistview([DCLV_USEARROWS, TRUE,
  24.                          DCLV_LABEL, 'Label',
  25.                          DCLV_RELX, 15,
  26.                          DCLV_RELY, 8,
  27.                          DCLV_LIST, list,
  28.                          DCLV_CURRENT, result,
  29.                          DCLV_TEXTATTR, attr,
  30.                          TAG_DONE])
  31.   easyguiA('Double Click test',
  32.           [EQROWS,
  33.             [DCLIST, {listaction},dclist,TRUE],
  34.             [EQCOLS,
  35.               [SBUTTON, {okaction}, '_OK', dclist, "o"],
  36.               [SBUTTON, {disable}, '_Disable', dclist, "d"],
  37.               [SBUTTON, {cancelaction}, '_Cancel', NIL, "c"]
  38.             ]
  39.           ])
  40. EXCEPT DO
  41.   END dclist
  42.   IF exception<>"QUIT" THEN report_exception()
  43. ENDPROC
  44.  
  45. PROC listaction(info, dclist:PTR TO dclistview)
  46.   IF dclist.get(DCLV_CLICK) THEN okaction(dclist, NIL)
  47.   PrintF('Current Selection: \d\n',dclist.get(DCLV_CURRENT))
  48. ENDPROC
  49.  
  50. PROC okaction(dclist:PTR TO dclistview, info)
  51.   IF (result:=dclist.get(DCLV_CURRENT))= -1
  52.     PrintF('No selection made\n')
  53.     cancelaction(info)
  54.   ENDIF
  55.   PrintF('Final Selection: \d\n',result)
  56.   quitgui(result)
  57. ENDPROC
  58.  
  59. PROC disable(dclist:PTR TO dclistview, info) IS dclist.setA([DCLV_DISABLED, dclist.get(DCLV_DISABLED)=FALSE,TAG_DONE])
  60.  
  61. PROC cancelaction(info)
  62.   PrintF('Operation cancelled.\n')
  63.   quitgui()
  64. ENDPROC
  65.  
  66. vers: CHAR 0, '$VER: dclisttest 1.6 (19.1.99)', 0
  67.  
  68.